package com.wlstock.funi.model;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.maxleap.MLObject;
import com.wlstock.funi.utils.CaculateUtils;
import com.wlstock.funi.utils.TimeUtils;

import java.util.Date;

/**
 * Created by admin on 16/6/14.
 */

@DatabaseTable
public class StrategyFundModel extends  BaseModel{
    @DatabaseField(generatedId = true)
    private int  id;
    @DatabaseField
    private String stkNo;
    @DatabaseField
    private String stkName;
    @DatabaseField
    private int tradeType;
    @DatabaseField
    private float tradePrice;

    @DatabaseField//最高年化
    private float highYearPecentage;
    @DatabaseField//最高年化持仓时间
    private int highYearKeepDays;

    @DatabaseField//最大成功率
    private float maxSuccessPecentage;
    @DatabaseField//最大成功率持有时间
    private int maxSuccessKeepDays;

    @DatabaseField(uniqueCombo = true)
    private String strategyShortName;
    @DatabaseField(uniqueCombo = true)
    private String strategyFullName;
    @DatabaseField(uniqueCombo = true)
    private String createDate;
    @DatabaseField
    private Date createTime ;

    public StrategyFundModel(){};

    public StrategyFundModel(StrategyModel strategyModel){
        this.strategyFullName  = strategyModel.getFullName();
        this.strategyShortName = strategyModel.getShortName();
        this.highYearKeepDays  = strategyModel.getHighYearKeepDays();
        this.highYearPecentage = strategyModel.getHighYearPecentage();
        this.maxSuccessKeepDays = strategyModel.getMaxSuccessKeepDays();
        this.maxSuccessPecentage = strategyModel.getMaxSuccessPecentage();
        this.createTime   = new Date();
    };

    public void setStkNo(String stkNo) {
        this.stkNo = stkNo;
    }

    public void setStkName(String stkName) {
        this.stkName = stkName;
    }

    public void setStrategyShortName(String strategyShortName) {
        this.strategyShortName = strategyShortName;
    }

    public void setStrategyFullName(String strategyFullName) {
        this.strategyFullName = strategyFullName;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public void setTradeType(int tradeType) {
        this.tradeType = tradeType;
    }

    public void setTradePrice(float tradePrice) {
        this.tradePrice = tradePrice;
    }

    public void setHighYearKeepDays(int highYearKeepDays) {
        this.highYearKeepDays = highYearKeepDays;
    }

    public String getStkNo() {
        return stkNo;
    }

    public String getStkName() {
        return stkName;
    }

    public String getStrategyShortName() {
        return strategyShortName;
    }

    public String getStrategyFullName() {
        return strategyFullName;
    }

    public String getCreateDate() {
        return createDate;
    }

    public int getTradeType() {
        return tradeType;
    }

    public float getTradePrice() {
        return tradePrice;
    }

    public int getHighYearKeepDays() {
        return highYearKeepDays;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public float getHighYearPecentage() {
        return highYearPecentage;
    }

    public void setHighYearPecentage(float highYearPecentage) {
        this.highYearPecentage = highYearPecentage;
    }

    public float getMaxSuccessPecentage() {
        return maxSuccessPecentage;
    }

    public void setMaxSuccessPecentage(float maxSuccessPecentage) {
        this.maxSuccessPecentage = maxSuccessPecentage;
    }

    public int getMaxSuccessKeepDays() {
        return maxSuccessKeepDays;
    }

    public void setMaxSuccessKeepDays(int maxSuccessKeepDays) {
        this.maxSuccessKeepDays = maxSuccessKeepDays;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public StrategyFundModel(MLObject mlObject){

    }

    @Override
    public String toString() {
        return "最高年化:"+ CaculateUtils.getPercentByFloat(highYearPecentage)+" 持有:(+"+highYearKeepDays+"天)\n"+
                "最大成功率:"+ CaculateUtils.getPercentByFloat(maxSuccessPecentage)+" 持有:(+"+maxSuccessKeepDays+"天)\n"+
                "加入时间:"+createDate+" 已经过去:"+ TimeUtils.dateDiff(createTime,new Date(), TimeUtils.TIME_PERIOD.DAY)+"天\n"+
                strategyFullName;
    }
}
